import {uniqueId} from 'lodash'

/**
 * @description 给菜单数据补充上 path 字段
 * @description https://github.com/d2-projects/d2-admin/issues/209
 * @param {Array} menu 原始的菜单数据
 */
function supplementPath (menu) {
    return menu.map(e => ({
        ...e,
        path: e.path || uniqueId('d2-menu-empty-'),
        ...e.children ? {
            children: supplementPath(e.children)
        } : {}
    }))
}

// 菜单 顶栏
export const menuHeader = supplementPath([
    /*{ path: '/index', title: '仪表盘', icon: 'home' },
    {
        title: '页面',
        icon: 'folder-o',
        children: [
            { path: '/page1', title: '页面 1' },
            { path: '/page2', title: '页面 2' },
            { path: '/page3', title: '页面 3' }
        ]
    }*/
])


// 菜单 侧边栏
export const menuAside = supplementPath([
    { path: '/index', title: '仪表盘', icon: 'home' },
    {
        title: '异常中心',
        icon: 'folder-o',
        children: [
            { path: '/page/abnormal/list', title: '异常列表' }
        ]
    },
    {
        title: '识别中心',
        icon: 'folder-o',
        children: [
            { path: '/page/discern/list', title: '物体识别信息' },
            { path: '/page/discern/statistics', title: '地理位置统计信息' }
        ]
    },
    {
        title: '测距中心',
        icon: 'folder-o',
        children: [
            { path: '/page/ruler/list', title: '测距列表' }
        ]
    },
    {
        title: '管理中心',
        icon: 'folder-o',
        children: [
            { path: '/page/manage/list', title: '管理员列表' }
        ]
    }
])
